/**
 * cesiumState
 */
import { defineStore } from "pinia";
import { ref, computed } from "vue";
import { CustomViewer } from "@@/utils/CustomCesium/CustomCesium";

export interface CesiumState {
  customViewer: CustomViewer | null;
}

export const cesiumState = defineStore("cesium-store", () => {
  const customViewer = ref<CustomViewer | null>(null);

  const getCustomViewer = computed(() => customViewer.value);

  function setCustomViewer(viewer: CustomViewer | null) {
    customViewer.value = viewer;
  }

  return {
    customViewer,
    getCustomViewer,
    setCustomViewer
  };
});

// 向后兼容，提供与原名称相同的导出
export const useCesiumStore = cesiumState;
